package jfinal.demo.login;

import com.jfinal.core.Controller;
import com.sun.prism.impl.Disposer;
import jfinal.demo.blog.BlogService;
import jfinal.demo.common.model.User;

public class LoginController extends Controller {

    static UserService service = new UserService();
    public void index(){
        String name = getPara("username");
        String password = getPara("password");
        User user = service.login(name,password);
        if(user ==null){
            setAttr("errormsg","用户名/密码错误！");
            render("/login/login.html");
        }else {
            setCookie("userid",user.getId()+"",10800);
            redirect("/main");
        }
    }
}
